from sqlalchemy import Column, Integer, String, DateTime, Index
from sqlalchemy.sql import func
from app.services.db import Base

class StockDict(Base):
    __tablename__ = "stock_dict"

    id = Column(Integer, primary_key=True, index=True)
    code = Column(String(12), unique=True, index=True, nullable=False)
    name = Column(String(200), nullable=False)
    exchange = Column(String(8), index=True, nullable=True)
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), index=True)

    __table_args__ = (
        Index("ix_stock_dict_code_exchange", "code", "exchange", unique=False),
    )